package websocketUtil

import (
	"fmt"
	"github.com/gorilla/websocket"
	"log"
	"time"
)

func SendMessagesToClient(ws *websocket.Conn, messageStr string) {
	// 构造要发送的消息
	message := fmt.Sprintf("Server time: %s WebSocketMessage: %s", time.Now().Format(time.RFC3339), messageStr)
	err := ws.WriteMessage(websocket.TextMessage, []byte(message))
	if err != nil {
		log.Println("Error sending message to client:", err)
		return
	}
}
